#ifndef WATCHDOG_H
#define WATCHDOG_H

#define WATCHDOG_IOCTL_BASE 'W'
#define WDIOC_GETSUPPORT _IOR(WATCHDOG_IOCTL_BASE, 0, struct watchdog_info)
#define WDIOC_SETTIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 6, int)
#define WDIOC_GETTIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 7, int) //27
#define WDIOS_DISABLECARD 0x0001   
#define WDIOS_ENABLECARD 0x0002
#define WDIOC_SETOPTIONS _IOR(WATCHDOG_IOCTL_BASE, 4, int)
#define WDIOC_KEEPALIVE _IOR(WATCHDOG_IOCTL_BASE, 5, int)

extern "C" {
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <unistd.h>
    #include <fcntl.h>
    #include <sys/ioctl.h>
    #include <errno.h>
    #include <sys/time.h>
    #include <unistd.h>
    #include <time.h>
    #include <getopt.h>
    #include <sys/signal.h>
    #include <termios.h>
}

#include <string>
#include <iostream>


struct watchdog_info{
    unsigned int options;   //options the card/driver supprots 19  
    unsigned int firmware_version;  //firmcard version of the card
    unsigned char identity[32];     //identity of the board 21
};

class watchdog
{
private:
    /* data */
    int fd;//句柄
    int time;//当前的超时时间
    struct watchdog_info wi;
public:
    watchdog();
    ~watchdog();

    int init(std::string dev);        //打开看门狗
    int getWatchDogInfo();            //获取看门狗信息
    int getWatchDogTime();            //获取看门狗超时时间
    int setWatchDogTime(int time);    //设置看门狗超时时间
    int disab();              //停止看门狗功能
    int enab();               //使能看门狗功能
    int feedDog();                    //喂狗函数
    int dev_close();
};





#endif